<?php
class Rs {
	
	static function indexar($rs, $index = 'id') {
		$rsIndex = array();
		if (is_array(current($rs))) {
			foreach ($rs as $r)	{
				$rsIndex[$r[$index]] = $r;
			}
		} else {
			foreach ($rs as $r)	{
				$rsIndex[$r->$index] = $r;
			}
		}
		return $rsIndex;
	}
	
	static function indexToArray($rs, $index = 'id') {
		$rsIndex = array();
		foreach ($rs as $r)	{
			$rsIndex[$r->$index] = (array)$r;
		}
		return $rsIndex;
	}
	
}